<?php defined('_JEXEC') or die('Restricted access'); ?> 
<?php $edit=JRequest::getVar( 'edit', true );?>
<?php $this->_ToolbarEdit($edit, $this->cid);?>
<?php JHTML::_('script'    , 'janews.js', 'administrator/components/com_janews/assets/'); ?>
<?php $frontpage = $this->frontpage; ?>
<div id="janews-main">
<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
			// do field validation
		form.title.value = trim(form.title.value);
		if (form.title.value == ""){
			alert( "<?php echo JText::_( 'FRONTPAGE LAYOUT MUST CONTAIN A TITLE', true ); ?>" );
		} else	if (form.blog.value == "-1"){
			alert( "<?php echo JText::_( 'FRONTPAGE LAYOUT MUST HAVE A BLOG TEMPLATE', true ); ?>" );
		}
		else	if (form.secsSelect.options.length==0) {
  		alert( "<?php echo JText::_( 'SELECT A SECTION TO DISPLAY FROM THE LIST', true ); ?>" );
	  }
	  else {
	    var temp = new Array;
  		for (var i=0, n=form.secsSelect.options.length; i < n; i++) {
  			temp[i] = form.secsSelect.options[i].value;
  		}
  		form.secs.value = temp.join(',');
  		submitform( pressbutton )
	  }
    
	}
</script>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col width-50">
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'Details' ); ?></legend>
		<table class="admintable">
		<tr>
			<td width="100" align="right" class="key">
				<label for="title">
					<?php echo JText::_( 'FRONTPAGE LAYOUT TITLE' ); ?>:
				</label>
			</td>
			<td>
			 <input class="inputbox" type="text" name="title" id="title" maxlength="50" size="50" value="<?php echo $frontpage->title; ?>" />
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="title">
					<?php echo JText::_( 'HEADLINE TEMPLATE' ); ?>:
				</label>
			</td>
			<td>
			<?php
			  $choosed = $edit ? (int)$frontpage->headline : -1;
				echo JHTML::_('select.genericlist',$this->headlines,'headline', 'size="1" class="inputbox"', 'value', 'text',(int)$choosed);
			?>
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="title">
					<?php echo JText::_( 'BLOG TEMPLATE' ); ?>:
				</label>
			</td>
			<td>
			<?php
			  $choosed = $edit ? (int)$frontpage->blog : -1;
		    echo JHTML::_( 'select.genericlist', $this->blogs, 'blog', 'size="1" class="inputbox"', 'value', 'text',(int)$choosed);
		  ?>
			</td>
		</tr>
	</table>
	</fieldset>

	<fieldset class="adminform">
		<legend><?php echo JText::_( 'CHOOSE SECTIONS TO DISPLAY' ); ?></legend>
	<table class="admintable" width="100%">
		<tr>
			<td width="48%" valign="top">
				<div align="center">
					<?php echo JText::_( 'SECTIONS' ); ?>:
					<br />
					<?php echo JHTML::_( 'select.genericlist', $this->list_secs, 'secsChoose[]','multiple="multiple" class="inputbox" size="10" onDblClick= movSelectedToList("adminForm","secsChoose","secsSelect"); ','value', 'text', explode(',', $this->str_secids));?>
				</div>
			</td>
			<td width="2%">
				<input class="button" type="button" value=">>" onclick="movSelectedToList('adminForm','secsChoose','secsSelect');" title="Add" />
				<br /><br/>
				<input class="button" type="button" value="<<" onclick="movSelectedToList('adminForm','secsSelect','secsChoose')" title="Remove" />
			</td>
			<td width="48%">
				<div align="center" valign="top">
					<?php echo JText::_( 'SECTION TO DISPLAY' ); ?>:
					<br />
					<?php if (!$this->secSelect) $this->secSelect = $this->list_secs; ?>
					
					<?php echo JHTML::_( 'select.genericlist', $this->secSelect, 'secsSelect[]','multiple="multiple" class="inputbox" size="10" onDblClick= movSelectedToList("adminForm","secsSelect","secsChoose"); ','value', 'text');?>
			</td>
			<td width="2%">
				 <input class="button" type="button" value="Move Up" onclick="moveInList('adminForm','secsSelect',adminForm.secsSelect.selectedIndex,-1)" />
				 <br /><br/>
				 <input class="button" type="button" value="Move Down" onclick="moveInList('adminForm','secsSelect',adminForm.secsSelect.selectedIndex,+1)" />
			</td>							
		</tr>
  </table>
	</fieldset>
</div>
<div class="clr"></div>
<input type="hidden" name="option" value="com_janews" />
<input type="hidden" name="edit" value="<?php echo $edit ?>" />
<input type="hidden" name="cid" value="<?php echo $this->cid; ?>" />
<input type="hidden" name="secs" value="" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="frontpage" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
</div>